package com.jnu.hc.jnuhcusercms.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebInterceptorConfig implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/**").order(10) // 拦截所有请求路径
                .excludePathPatterns("/login", "/register","/pay/**","/checkpayment","/refund"); // 排除某些路径

        registry.addInterceptor( new LoginInterceptor()).addPathPatterns("/**") // 拦截所有请求路径
                .excludePathPatterns("/login", "/register","/pay/**","/checkpayment","/refund").order(20); // 排除某些路径
    }

}
